<%-- 
    Document   : lab
    Created on : 2019-2-17, 16:53:57
    Author     : dusin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    session.setAttribute("url", "../main/siterstat.jsp");
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>        
        <link rel="stylesheet" href="../../js/jquery/themes/default/easyui.css" type="text/css" />
        <link rel="stylesheet" href="../../js/jquery/themes/icon.css" type="text/css" />
        <link rel="stylesheet" href="../../js/jquery/themes/color.css" type="text/css" />
        <link rel="stylesheet" href="../../css/demo.css" type="text/css" />
        <script type="text/javascript" src="../../js/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="../../js/jquery/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="../../js/jquery/locale/easyui-lang-zh_CN.js"></script>
        <script type="text/javascript">
            function toUrlParamString(param, key) {
                var paramStr = "";
                if (param instanceof String || param instanceof Number || param instanceof Boolean) {
                    paramStr += "&" + key + "=" + encodeURIComponent(param);
                } else {
                    $.each(param, function(i) {
                        var k = key == null ? i : key + (param instanceof Array ? "[" + i + "]" : "." + i);
                        paramStr += '&' + toUrlParamString(this, k);
                    });
                }
                return paramStr.substr(1);
            };
            //格式化日期
            /*function myformatter(date) {
                //获取年份
                var y = date.getFullYear();
                //获取月份
                var m = date.getMonth() + 1;
                return y + '-' + m;
            }
            //只显示年月*/
           
            $(document).ready(function() {
                
                $('#dgstudent').datagrid({                   
                    height: ($(window).height() - 3) + 'px'
                });
                 /*$(function() {

                $('#ddMonth').datebox({
                    //显示日趋选择对象后再触发弹出月份层的事件，初始化时没有生成月份层
                    onShowPanel: function() {
                        //触发click事件弹出月份层
                        span.trigger('click');
                        if (!tds)
                            //延时触发获取月份对象，因为上面的事件触发和对象生成有时间间隔
                            setTimeout(function() {
                                tds = p.find('div.calendar-menu-month-inner td');
                                tds.click(function(e) {
                                    //禁止冒泡执行easyui给月份绑定的事件
                                    e.stopPropagation();
                                    //得到年份
                                    var year = /\d{4}/.exec(span.html())[0],
                                            //月份
                                            //之前是这样的month = parseInt($(this).attr('abbr'), 10) + 1; 
                                            month = parseInt($(this).attr('abbr'), 10);

                                    //隐藏日期对象                     
                                    $('#ddMonth').datebox('hidePanel')
                                            //设置日期的值
                                            .datebox('setValue', year + '-' + month);
                                });
                            }, 0);
                    },
                    //配置parser，返回选择的日期
                    parser: function(s) {
                        if (!s)
                            return new Date();
                        var arr = s.split('-');
                        return new Date(parseInt(arr[0], 10), parseInt(arr[1], 10) - 1, 1);
                    },
                    //配置formatter，只返回年月 之前是这样的d.getFullYear() + '-' +(d.getMonth()); 
                    formatter: function(d) {
                        var currentMonth = (d.getMonth() + 1);
                        var currentMonthStr = currentMonth < 10 ? ('0' + currentMonth) : (currentMonth + '');
                        return d.getFullYear() + '-' + currentMonthStr;
                    }
                });

                //日期选择对象
                var p = $('#ddMonth').datebox('panel'),
                        //日期选择对象中月份
                        tds = false,
                        //显示月份层的触发控件
                        span = p.find('span.calendar-text');
                var curr_time = new Date();

                //设置前当月
                $("#ddMonth").datebox("setValue", myformatter(curr_time));
            });*/
            $('#ddDate').datebox('setValue','Today');
                $('#type').combobox({
                    onSelect: function(record) {
                        if (record.value == 2) {
                            
                            //$('#ddMonth').hide();                            
                        } else {
                            //$('#ddDate').show();
                            //$('#ddMonth').hide();  
                        }
                    }
                });
            });
            function exportExcel() {                
                var params = {
                    
                    type: $('#type').combobox('getValue'),
                    dateFrom: $('#ddDate').datebox('getValue')
                };
                var urlStr = toUrlParamString(params);
                //alert(urlStr);
                var url = '../../servlet/util/ExcelFile4SiterStat?' + urlStr;
                //open(encodeURI(url));
                open(url);
            }
            function doSearch() {
                $('#dgstudent').datagrid('load', {                   
                    type: $('#type').combobox('getValue'),
                    dateFrom: $('#ddDate').datebox('getValue'),                    
                });
            }
        </script>
    </head>
    <body class="easyui-layout">        
        <table id="dgstudent" title="驻厂员数据统计" class="easyui-datagrid"
               url="../../servlet/web/cargo/LoadSiterStat"
               toolbar="#toolbar"
               rownumbers="true" fitColumns="true" singleSelect="true">
            <thead>
                <tr>                    
                    <th data-options="field:'ZCYName',width:80" rowspan="2"><center>驻厂员</center></th>
                    <th data-options="field:'KHName',width:200" rowspan="2"><center>客户工厂</center></th>
                    <th data-options="field:'GYSName',width:200" rowspan="2"><center>供应商</center></th>
                    <th data-options="field:'CheCis',width:60,align:'right'" rowspan="2"><center>车数</center></th>
                    <th colspan="4">照片上传数量</th>
                    <th data-options="field:'isQuanS',width:80,align:'right'" rowspan="2"><center>磅单数据<br/>完整数量</center></th>
                    <th data-options="field:'netWeights',width:80,align:'right'" rowspan="2"><center>总吨数</center></th>
                </tr>
                <tr>
                    <th data-options="field:'PFronts',width:40,align:'right'"><center>头</center></th>
                    <th data-options="field:'Psides',width:40,align:'right'"><center>货</center></th>
                    <th data-options="field:'PLicenses',width:40,align:'right'"><center>证</center></th>
                    <th data-options="field:'PPapers',width:40,align:'right'"><center>单</center></th>
                </tr>
            </thead>
        </table>
        <div id="toolbar">
            <select class="easyui-combobox" name="type" id="type"
                    style="width:100px"                                   
                    editable:false> 
                <option value="1">按日统计</option>
                <option value="2">按月统计</option>
            </select>
            <input id="ddDate" type="text" class="easyui-datebox"  data-options="prompt:'选择统计日',editable:false">
            <!--<input id="ddMonth" type="text" class="easyui-datebox"  data-options="prompt:'选择统计月',editable:false,hidden:true">-->
            <a href="#" class="easyui-linkbutton" iconCls="icon-stat" plain="true" onclick="doSearch()">统计</a>            
            <a href="#" class="easyui-linkbutton" iconCls="icon-excel" plain="true" onclick="exportExcel()">导出</a>
        </div>        
    </body>
</html>
